package com.example.controller;

import com.example.pojo.Result;
import com.example.pojo.repairTestingPojo;
import com.example.service.repairTestingService;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * ClassName:repairTestingController
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/5/15 9:54
 * @Version 1.0
 */
@RestController
@Slf4j
public class repairTestingController {
    @Autowired
    private repairTestingService repairTestingService;
//根据点击的导航栏，查询对应的检测数据
    @PostMapping("/repairTestingList")
    public Result repairTestingList(@RequestBody repairTestingPojo repairTestingPojo){
        List<repairTestingPojo> repairTesting = repairTestingService.repairTestingList(repairTestingPojo);
        return Result.success(repairTesting);
    }
    //对每行中的“编辑”按钮，传来的文件写入到磁盘以及数据库中
    @PutMapping("/TestingModifySteps")
    public Result TestingModifySteps(@RequestPart("tableDataTemp") String tableDataTempJson, @RequestPart("fileListV") List<MultipartFile> fileListV) throws JsonProcessingException {
        repairTestingService.TestingModifySteps(tableDataTempJson,fileListV);
        return Result.success();
    }
    //修改检查记录中的数据
    @PutMapping("/TestingModifyStepsString")
    public Result TestingModifyStepsString(@RequestBody repairTestingPojo repairTestingPojo){
        log.info(repairTestingPojo.toString());
        //保存数据，不能保存图片路径信息
        repairTestingService.TestingModifyStepsString(repairTestingPojo);
        return Result.success("保存成功");
    }

}
